import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import AutoImport from 'unplugin-auto-import/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import pxtovw from 'postcss-px-to-viewport-8-plugin'
import { resolve } from 'path';


// https://vitejs.dev/config/
export default defineConfig({
    //插件数组
    plugins: [
        vue(),
		AutoImport({
			resolvers: [ElementPlusResolver()],
		}),
		Components({
			resolvers: [ElementPlusResolver()],
		}),
    ],
	base: '/',
	publicDir:'public',
	css: {
		postcss:{
			plugins: [pxtovw({
				viewportWidth: 1920, // 视窗的宽度，对应的是我们设计稿的宽度.
				unitPrecision: 5, // 保留几位小数，指定`px`转换为视窗单位值的小数位数（很多时候无法整除）
				viewportUnit: 'vw', // 指定需要转换成的视窗单位，建议使用vw
				fontViewportUnit: 'vw',//字体使用的视口单位
				minPixelValue: 1, // 小于或等于`1px`不转换为视窗单位.
				mediaQuery: false ,// 允许在媒体查询中转换`px`
				exclude: /(node_module)/
			})]
		},
		preprocessorOptions: {
			scss: {
				additionalData: '@use "@/styles/globalVar.scss" as  *;',
			}
		}
	},
	resolve:{
		alias: {
			'@': resolve(__dirname , 'src'),
		},
	},
	server:{
		host: '0.0.0.0',
		port: 3041,
		open: false,
		// 是否开启 https
		https: false,
		// 代理
		proxy: {
			
		}
	},
	
	build:{
		outDir:'dist',
		assetsDir: 'assets',
	},
	preview:{
		
	}
})
